﻿#ifndef LIGHTCONTROLLER_H
#define LIGHTCONTROLLER_H


#include <QObject>
#include <QtSerialPort/QtSerialPort>
#include "LampControl/common/lampcontrol.h"

namespace dgkoma {

/**
 * @brief The LightController class 东莞科麦视觉科技有限公司的光源控制器的控制代码
 *          暂时只支持 2 个通道。
 */
class LightController : public Qly::LampControl
{
    Q_OBJECT
public:

    explicit LightController(QObject *parent = nullptr);

    void loadSettings(QSettings &settings);
    void writeSettings(QSettings &settings);
    bool open(QString comm);
    bool close();

    bool setValue(uint8_t ch, int level) override;
    bool value(uint8_t ch, int & level) override;
    bool turnOn(uint8_t ch) override;
    bool turnOff(uint8_t ch) override;

    void onLensChanged(int old, int newLens) override;
private:
    QSerialPort * m_serialPort;    

    int m_value[2];
    int m_cmd;
};
}


#endif // LIGHTCONTROLLER_H
